﻿using Modules.Project.Entitys;
using System.Diagnostics.CodeAnalysis;

namespace Modules.Project.Comparers;

internal class ProjectCorpComparer : IEqualityComparer<ProjectCorp>
{
    public bool Equals(ProjectCorp? x, ProjectCorp? y)
    {
        if (x == null && y == null)
            return true;
        else if (x == null || y == null)
            return false;
        else if (x.ProjectId == y.ProjectId && x.CorpId == y.CorpId && x.Role == y.Role)
            return true;
        else
            return false;
    }

    public int GetHashCode([DisallowNull] ProjectCorp obj)
    {
        return $"{obj.ProjectId}{obj.CorpId}{obj.Role}".GetHashCode();
    }
}